<%@ 
page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>

<%@page import="com.lovo.bbs.vo.*,java.util.*"%>

<%
	//取得帖子列表
	ArrayList postList = (ArrayList) request.getAttribute("postList");
	//取得主题信息
	TopicVo topicInfo = (TopicVo) request.getAttribute("topicInfo");
	//取得论坛信息
	int forumid = topicInfo.getForumid();
	HashMap<Integer, ForumVo> forumMap = (HashMap<Integer, ForumVo>) request
			.getAttribute("forumMap");
	ForumVo forumSimple = (ForumVo) forumMap.get(forumid);
	//取得等级信息
	HashMap<Integer, RankVo> rankMap = (HashMap<Integer, RankVo>) request
			.getAttribute("rankMap");
	//取得网站杂项信息
	ForumStatVo forumInfo = (ForumStatVo) request
			.getAttribute("forumInfo");

	//贴子数
	int postNum = (Integer) request.getAttribute("postNum");
	//请求页码
	int queryPage = (Integer) request.getAttribute("queryPage");
	//页数
	int pageNum = (Integer) request.getAttribute("pageNum");

	Iterator it, it2;

	LoginVo loginvo = (LoginVo) session.getAttribute("loginvo");

	//记住上一次的主题列表页的页数
	String backpage = request.getParameter("backpage");
	if (backpage == null) {
		backpage = "1";
	}
	//是否定位到最后回帖
	String end = request.getParameter("end");
	if (end == null) {
		end = "0";
	}
	//当请求最后页时,自动滚动到页面低端
	if (queryPage == pageNum) {
		end = "1";
	}
%>

<html>
	<head>
		<title><%=topicInfo.getTopicTitle()%> - <%=forumInfo.getSiteName()%></title>
		<meta name="description"
			content=" <%=topicInfo.getTopicTitle()%>,<%=forumInfo.getSiteName()%>" />
		<meta name="keywords"
			content="<%=topicInfo.getTopicTitle()%>,<%=forumInfo.getSiteName()%> " />

		<link href="css/style.css" type="text/css" rel=stylesheet />
		<link href="css/menu.css" type="text/css" rel=stylesheet />
		<link href="css/common.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" src="js/vbulletin_global.js"></script>
		<script type="text/javascript" src="js/vbulletin_menu.js"></script>
		<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
		<script type="text/javascript" src="js/wbs_common.js"></script>
		<script type="text/javascript" src="js/wbs_ajax.js"></script>
		<script type="text/javascript" src="js/wbs_dragdrop.js"></script>
		<script type="text/javascript" src="js/wbs_popup.js"></script>
		<script type="text/javascript">var IMGDIR_MISC = "";</script>
	</head>

	<body <%if("1".equals(end)){ %>
		OnLoad="javascript:scroll(document.body.scrollWidth ,document.body.scrollHeight)"
		<%} %>>
		<div id="overlay"></div>
		<div id=popLayer style="position: absolute; z-index: 101"
			class=cPopText></div>
		<table width="100%" align="center" cellpadding="0" cellspacing="1"
			class="CommonNavigation_OuterTableCSS">
			<tr>
				<td>
					<table width="100%" cellpadding="9" cellspacing="0">
						<tr>
							<td class="CommonNavigation_InnerTableFooterCSS">
								<table width="100%" cellpadding="0" cellspacing="0" board="1">
									<tr>


										<!--登录状态----------------------------------------------------------------->
										<td class="SmallTxt">
											<%
												if (session.getAttribute("loginvo") == null) {
											%>
											<font class="SmallGrayText">欢迎: <b>游客</b> </font>
											<font class="SmlLinks">( </font><a href="javascript:void(0)"
												onclick="openLogin()">登陆</a><font class="SmlLinks"> |
											</font><a href="javascript:void(0)" onclick="openRegister()">注册</a><font
												class="SmlLinks"> )</font>


											<!--注册窗口----------------------------------------------------------------->
											<%@include file="include/regWindow.html"%>

											<%
												} else {
													loginvo = (LoginVo) session.getAttribute("loginvo");
											%>
											欢迎:
											<em id="logedusername" value="<%=loginvo.getUserName()%>">
												<a href="userinfo.jsp?username=<%=loginvo.getUserName()%>"><%=loginvo.getUserName()%></a>
											</em>
											<font class="SmlLinks">( </font><a href="javascript:void(0)"
												onclick="logout()">退出</a><font class="SmlLinks"><font
												class="SmlLinks"> )</font>&nbsp;&nbsp; <a
												class="FunctionDesk" href="control/control.jsp?username=<%=loginvo.getUserName()%>">控制面板</a> <%
 	}
 %> </font>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<font size="1"><br> </font>
		<font size="1"><br> </font>



		<!--导航栏----------------------------------------------------------------->
		<table width="100%" cellpadding="0" cellspacing="1"
			class="BreadCrumb_OuterTableCSS">
			<tr>
				<td>
					<table width="100%" cellpadding="9" cellspacing="0"
						class="BreadCrumb_InnerTableCSS">
						<tr>
							<td>
								<a title="首页" class="SmlBoldLinks" href="index.jsp"><%=forumInfo.getSiteName()%></a>
								<font class="BreadCrumb_NavSeperator">&#187;</font>
								<a title="返回<%=forumSimple.getForumName()%>"
									class="SmlBoldLinks"
									href="forum.jsp?fid=<%=forumid%>&page=<%=backpage%>"><%=forumSimple.getForumName()%></a>
								<font class="BreadCrumb_NavSeperator">&#187;</font>
								<a><%=topicInfo.getTopicTitle()%></a>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>


		<!--页码----------------------------------------------------------------->
		<font size="1"><br> </font>
		<font size="1"><br> </font>
		<table width="100%" cellpadding="0" cellspacing="0">
			<tr>
				<td id="content_bar" align="left">
					<a class="content_total"><%=postNum - 1%>个回复 , 第<%=queryPage%>页
						总<%=pageNum%>页</a>
					<%
						for (int i = 1; i <= pageNum; i++) {
							if (i == queryPage) {
					%>
					<a class="content_pasges_c"><%=i%></a>
					<%
						} else {
					%>
					<a class="content_pasges_a"
						href="topic.jsp?tid=<%=topicInfo.getTopicid()%>&page=<%=i%>"><%=i%></a>
					<%
						}
						}
					%>
				</td>
				<td width="40%" align="right">
					<input class="input_btn" type="button" value="回复"
						<%if (loginvo!=null){%> onclick="openNewPost()" <%}else{%>
						onclick="openErrorLogin()" <%}%> />
					<input class="input_btn" type="button" value="发表主题"
						<%if (loginvo!=null){%> onclick="openNewTopic()" <%}else{%>
						onclick="openErrorLogin()" <%}%> />
				</td>
			</tr>
		</table>
		<font size="1"><br> </font>


		<table Class="forum_out" width="100%" border="0" cellpadding="0"
			cellspacing="0">
			<tr>
				<td>
					<table border="0" width="100%" cellpadding="0" cellspacing="0">
						<!--工具栏----------------------------------------------------------------->
						<tr>
							<td class="board" align="center">
								标题:<%=topicInfo.getTopicTitle()%>&nbsp;&nbsp;
								<a class="smalltext" id="forumtools"><b>工具栏</b> </a>
								<script type="text/javascript"> vbmenu_register("forumtools"); </script>
								<div class="vbmenu_popup" id="forumtools_menu"
									style="display: none">
									<table cellpadding="4" cellspacing="1" border="0">
										<tr>
											<td class="vbmenu_option" align="center">
												<a href="javascript:window.print()">打印本页</a>
											</td>
										</tr>
									</table>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<table width="100%" cellpadding="4" cellspacing="0">
									<tr>
										<td class="forumcell_read" colspan="4" align="center">
											<font class="smalltext"><b></b>&nbsp; </font>
										</td>
									</tr>
								</table>
								<%
									if (postList == null) {
										postList = new ArrayList();
									}
									it = postList.iterator();
									if (it != null) {
										int i = 1;
										while (it.hasNext()) {
											i++;
											PostVo postData = (PostVo) (it.next());
											RankVo rankData = (RankVo) rankMap
													.get(postData.getRankid());
								%>
								<table width="100%" cellpadding="4" cellspacing="0">
									<!--用户信息栏----------------------------------------------------------------->
									<tr>
										<td width="20%" class="post"
											style="padding: 0px; padding-left: 10px; padding-top: 8px;"
											bgcolor="#F0F5FA" valign="top">
											<a class="smalltext" href="" id="usertools#<%=i%>"><b><%=postData.getUsername()%></b>
											</a>
											<script type="text/javascript"> vbmenu_register("usertools#<%=i%>"); </script>
											<div class="vbmenu_popup" id="usertools#<%=i%>_menu"
												style="display: none">
												<table cellpadding="4" cellspacing="1" border="0">
													<tr>
														<td class="vbmenu_option" align="center">
															<a
																href="userinfo.jsp?username=<%=postData.getUsername()%>"
																target="_blank">查看资料</a>
														</td>
													</tr>

													<tr>
														<td class="vbmenu_option" align="center">
															<a href="javascript:alert('对不起!此功能暂未开放')"">发送短信</a>
														</td>
													</tr>
													<tr>
														<td class="vbmenu_option" align="center">
															<a href="javascript:alert('对不起!此功能暂未开放')"">QQ聊天</a>
														</td>
													</tr>
												</table>
											</div>
											<br>
											<span class="smalltext"><%=postData.getUsername()%></span>
											<br>
											<img height="90px"
												src="images/userhead/<%=postData.getHeadimg()%>">
											<br>
											<span class="smalltext"><%=rankData.getRankname()%></span>
											<br>
											<br>
											<img src="images/rank/<%=rankData.getRankimg()%>" border="0" />
											<br>
											<br>
											<span class="smalltext">头衔:<%=rankData.getRanktitle()%></span>
											<br>
											<br>
											<span class="smalltext">发表数: <%=postData.getUserTopicNum()%></span>
											<br>
											<br>
											<span class="smalltext">积分:<%=postData.getScore()%></span>
											<br>
											<br>
											<br>
										</td>
										<td width="80%" class="post" style="padding: 5px;"
											valign="top">
											<table width="100%" cellspacing="0" cellpadding="0">
												<tr>
													<td class="topiccell_button">
														<img src="images/Misc_PostDate.gif" border="0" hspace="5" />
														<font class="smalltext">发表时间: <%=postData.getPostdate()%>
														</font>
													</td>
												</tr>
												<tr>
													<td valign="top"
														style="padding-left: 20px; padding-top: 20px; font-size: 14px;">
														<%=postData.getContent()%>
													</td>
												</tr>
												<tr>
													<td valign="bottom">
														<br>
														<br>
														<br>
														<br>
														<br>
														<br>
														<br>
														<img src="images/sigline.gif" />
														<div
															style="font: 12px; overflow: hidden; max-height: 20em; maxHeightIE: 245px; padding-left: 20px">
															<%=postData.getSignature()%>
														</div>
													</td>
												</tr>
											</table>
										</td>
										<td valign="bottom" class="post" align="right">
											<table>
												<tr>
													<td valign="baseline" align="right" class="smalltext"
														class="post">
														<a title="返回顶部" onclick="javascript:scroll(0,0)"> <img
																src="images/top.gif" hspace="5"> </a>
													</td>
												</tr>
											</table>
										</td>
									</tr>
								</table>
								<br>
								<%
									}
									}
								%>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<font size="1"><br> </font>
		<table width="100%" cellpadding="0" cellspacing="0">
			<tr>
				<td id="content_bar" align="left">
					<a class="content_total"><%=postNum - 1%>个回复 , 第<%=queryPage%>页
						总<%=pageNum%>页</a>
					<%
						for (int i = 1; i <= pageNum; i++) {
							if (i == queryPage) {
					%>
					<a class="content_pasges_c"><%=i%></a>
					<%
						} else {
					%>
					<a class="content_pasges_a"
						href="topic.jsp?tid=<%=topicInfo.getTopicid()%>&page=<%=i%>"><%=i%></a>
					<%
						}
						}
					%>
				</td>
				<td width="40%" align="right">
					<input class="input_btn" type="button" value="回复"
						<%if (loginvo!=null){%> onclick="openNewPost()" <%}else{%>
						onclick="openErrorLogin()" <%}%> />
					<input class="input_btn" type="button" value="发表主题"
						<%if (loginvo!=null){%> onclick="openNewTopic()" <%}else{%>
						onclick="openErrorLogin()" <%}%> />
				</td>
			</tr>
		</table>
		<font size="1"><br> </font>
		<font size="1"><br> </font>
		<font size="1"><br> </font>


		<!--页脚----------------------------------------------------------------->
		<%@include file="include/copyright.html"%>

        <!--回复 ----------------------------------------------------------------->
		<form name="newpost" method="POST" action="NewPostServlet">
			<%@ include file="include/newpost.html"%>
			<input type="hidden" name="topicid"
				value="<%=topicInfo.getTopicid()%>">
			<input type="hidden" name="postforumid" value="<%=forumid%>">
            <%if (loginvo!=null){%>
			      <input type="hidden" name="postauthorname" value="<%=loginvo.getUserName() %>">
			<%} %>
		</form>

        <!--  主题----------------------------------------------------------------->
		<form method="POST" name="newtopic" action="NewTopicServlet">
			<%@ include file="include/newtopic.html"%>
			<input type="hidden" name="forumid" value="<%=forumid%>">
			<%if (loginvo!=null){%>
			      <input type="hidden" name="topicauthorname" value="<%=loginvo.getUserName() %>">
			<%} %>
		</form>
		
		<!--登录窗口 ----------------------------------------------------------------->
		<%@include file="include/loginWindow.html"%>
		<script type="text/javascript">
				vBulletin_init();
		</script>
	</body>
</html>
